<?php
include_once("includes/global.php");
include_once("includes/smarty_config.php");
include_once("includes/user_shop_class.php");
include_once("includes/point_inc.php");
//===============================================
$id=$_GET['id']*1;
$catid=$_GET['catid']*1;
$_GET['uid']*=1;
$list_type=empty($_GET['list_type'])?NULL:$_GET['list_type'];
$cat=empty($_GET['cat'])?NULL:$_GET['cat'];
$_GET['firstRow']=empty($_GET['firstRow'])?NULL:$_GET['firstRow'];
$action=isset($_GET['action'])?$_GET['action']:NULL;
//------------------------
user_read_rec($buid,$_GET['uid'],3);//记录会员查看商铺
//------------------------
$shop = new shop();
if(isset($_GET['spread'])&&is_numeric($_GET['spread']))
	$shop->site_spread($_GET['spread']);
//------------------------
$flag=md5($action.$_GET['uid'].$id.$_GET['firstRow'].$config['weburl'].$catid.$list_type.$cat);
if($action!="mail"&&$action!="comments"&&empty($_GET['template'])&&$buid!=$_GET['uid'])
{	
	$dir=get_userdir($_GET['uid']);//根据会员ID生成缓存目录
	useCahe('shop/'.$dir,true);
}
if(!$tpl->is_cached("space_temp_inc.htm",$flag))
{	
	$company=$shop->user_detail($_GET['uid']);
	if($company['shop_statu']!=1)
	{   //商铺被关闭或者资料不完整。
		$tpl->assign("com",$company);
		include_once("footer.php");
		$tpl->display('space_personal.htm');die;
	}
	else
	{
		//----------------------------------------------------
		$config_file=$config['webroot']."/config/shop_config/shop_config_".$_GET['uid'].'.php';
		if(file_exists($config_file))
			include_once($config_file);				
		else
			include_once($config['webroot']."/lang/".$config['language']."/shop_default_config.php");
		$tpl->assign("shopconfig",$shopconfig);
		//-----------------------------------------------------
		$tpl->assign("ulink",$shop->get_user_link());
		$tpl->assign("custom_cat",$shop->get_custom_cat_list(1));
		$tpl->assign("business_validate_statu",$bst=$shop->get_business_validate());
		//-------------------------语言包------------------------
		include_once("lang/".$config['language']."/user_space.php");
		//-------------------------module分发--------------------
		if(!empty($_GET['m'])&&!empty($_GET['action']))
		{
			if(file_exists("module/".$_GET['m']."/lang/".$config['language'].".php"))
				include("module/".$_GET['m']."/lang/".$config['language'].".php");//#调用模块语言包
			include("module/".$_GET['m']."/space_".$_GET['action'].".php");
		}
		else
		{
			$sql="select rec_pro from ".SHOPSETTING." where userid='$_GET[uid]'";
			$db->query($sql);
			$rec=$db->fetchField('rec_pro');
			$rec_pro=substr($rec,1,strlen($rec));
			$tpl->assign("rec_pro",$rec_pro);
			//--------------------
			$company_detail=$shop->get_user_detail($_GET['uid']);
			if(is_array($company_detail))
				$company=array_merge($company_detail, $company);
			$page  ="space_index.htm";
		}
		//--------------------------------------------
		$lang["seo_title"]=$company['company'];
		$lang["seo_keyword"]=$company['company'].','.$company['main_pro'];
		$lang["seo_description"]=strip_tags($company['intro']);
		
		$tpl->assign("com",$company);
		include_once("footer.php");
		//---------------------------------------------
		if(!empty($_GET['template']))
		{
			if(file_exists($config['webroot']."/templates/$_GET[template]"))
				$company['template']=$_GET['template'];
		}
		//-------------使用指定商铺模板。-----------------
		if(!empty($company['template']))
		{	
			$tpl -> template_dir = $config['webroot'] . "/templates/".$company['template']."/";
			$tpl -> compile_dir = $config['webroot'] . "/templates_c/".$company['template']."/";
			$tpl -> assign("imgurl","templates/".$company['template']."/img/");
			$config['temp']=$company['template'];
		}
		else
			$tpl->template_dir=$config['webroot']."/templates/".$config['temp']."/";
		//----------------------------------------------
		if(empty($output))
			$tpl->assign("output",$tpl->fetch($page?$page:"space_company.htm",$flag));
		else
			$tpl->assign("output",$output);
	}

}
$tpl ->display("space_temp_inc.htm",$flag);
?>